package com.drcoffee.drcoffeemall.controller;

import com.drcoffee.drcoffeemall.entry.Result;
import com.drcoffee.drcoffeemall.service.WeChatPayService;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/wechatPay")
public class WeChatPayController {

    @Autowired
    WeChatPayService weChatPayService;

    @GetMapping("/createPay")
    public Result createPay(@org.springframework.web.bind.annotation.RequestParam String order_code) {
        return weChatPayService.createPay(order_code);
    }

    @PostMapping("/notify")
    public Map<String, String> wechatNotify(HttpServletRequest request) {
        return weChatPayService.wechatNotify(request);
    }

    @PostMapping("/notifyRefund")
    public Map<String, String> notifyRefund(HttpServletRequest request) {
        return weChatPayService.notifyRefund(request);
    }

    @GetMapping("/payVerify")
    public Result payVerify(@RequestParam String order_code) {
        return weChatPayService.payVerify(order_code);
    }
}
